package com.infolab.aims.web.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;

public class RequestHeaderProcessingFilter extends AbstractAuthenticationProcessingFilter{

	private String usernameHeader = "j_username";
	private String passwordHeader = "j_password";


	protected RequestHeaderProcessingFilter() {
	    super("/login_direct");
	 }

	//getters and setters

	@Override
	public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
	    String username = request.getHeader(usernameHeader);
	    String password = request.getHeader(passwordHeader);

//	     SignedUsernamePasswordAuthenticationToken authRequest =
//	        new SignedUsernamePasswordAuthenticationToken(username, password);
//
//	      return this.getAuthenticationManager().authenticate(authRequest); 
	    return null;
	}
	}

